package com.mew.common.dc.redis;

import com.mew.common.config.RedisConstantValue;
import com.mew.common.entity.config.LevelVip;
import com.mew.common.exception.MewException;
import com.mew.common.exception.ResponseCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;


/**
 * @Date 2021/1/25 0025
 **/
@Service
@Slf4j
public class LevelConfigRedisService {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;


    public LevelVip getLevelVip(int vipId){
        LevelVip levelVip = (LevelVip) redisTemplate.opsForHash().get(RedisConstantValue.LEVEL_VIP, vipId);
        if (null == levelVip){
            throw new MewException(ResponseCode.LevelNotVip);
        }
        return levelVip;
    }
}
